#!/bin/sh

set -x

BRANCH="${GIT_BRANCH:-${TRAVIS_BRANCH}}"
[ "$BRANCH" = 'master' ] || exit

git checkout "$BRANCH"

go run script/genauthors/genauthors.go --format=markdown > AUTHORS.md

git config --global user.email 'fireworq.github@gmail.com'
git config --global user.name 'fireworq-bot'

git add AUTHORS.md
git commit -m "Update the list of authors."
git remote add github "https://${GH_TOKEN}@github.com/fireworq/fireworq.git" >/dev/null 2>&1
git push --quiet github master
